package pri.hillchen.springbootstd.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import pri.hillchen.springbootstd.entity.User;
import pri.hillchen.springbootstd.service.UserService;

/**
 * Created by hillchen on 2017/10/14.
 */
@Controller
public class LoginController {
    @Autowired
    private UserService userService;
    @RequestMapping("/index")
    public String index(){
        return "index";
    }

    @RequestMapping("/login")
    public String login(){
        return "login";
    }

    @RequestMapping("/userLogin")
    public ModelAndView userLogin(String userName, String password){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("userInfo");
        User user = userService.findUserByUserNamePassword(userName,password);
        modelAndView.addObject("user",user);
        modelAndView.addObject("hello","hello");
        return modelAndView;
    }
}
